﻿@using Ecommerce.Models
@using Library
@model Library.Models.ProductCulture

@{
    ViewBag.Title = string.Format(NOWCulture.GetString("Gallery") + " '{0}'", Model.Name);
    Layout = "_Layout.cshtml";

    var images = ViewBag.Images as List<ProductImageViewModel>;
    System.Diagnostics.Debug.Assert(images != null, "images != null");
}

<h2>@ViewBag.Title</h2>
<a class="btn btn-warning" href="@Url.Action("Products")" title="@NOWCulture.GetString("Go back")"><span class="glyphicon glyphicon-arrow-left"></span> @NOWCulture.GetString("Go back")</a>
<button type="button" class="btn btn-success" data-editor="create" data-productid="@Model.ProductId" data-imgsrc=""><span class="glyphicon glyphicon-plus"></span>@NOWCulture.GetString("Create new")</button>
<div class="gallery">
    @foreach (var image in images)
    {
        @Html.Partial("_ProductImageView", image)
    }
</div>
@Html.Action("ConfirmDialog", "Shared", new
{
    title = NOWCulture.GetString("Remove") + " " + NOWCulture.GetString("page group"),
    content = string.Format(NOWCulture.GetString("Are you sure you want to remove this {0}?"), NOWCulture.GetString("page group"))
})
<div class="modal fade" id="editorModal" tabindex="-1" role="dialog" aria-labelledby="modalLabel" aria-hidden="true">
    <div class="modal-dialog modal-lg">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="@NOWCulture.GetString("Close")"><span aria-hidden="true">&times;</span></button>
                <h4 class="modal-title pull-left" id="modalLabel">@NOWCulture.GetString("Create new")/@NOWCulture.GetString("Edit") @NOWCulture.GetString("product image")</h4>
                <div class="pull-right langarea">
                    @foreach (var dic in NOWCulture.Dictionary)
                    {
                        var langName = NOWCulture.GetString(dic.Key.Name);
                        <button type="button" class="btn btn-default btn-xs" data-culture="@dic.Key.Id"><img src="~/Content/cultures/@dic.Key.Id/icon.png" alt="@langName" width="16" height="16" /> @langName</button>
                    }
                </div>
                <div class="clearfix"></div>
            </div>
            <div class="modalloading" id="editorModalLoading">
                <span class="glyphicon glyphicon-refresh glyphicon-refresh-animate"></span> @NOWCulture.GetString("Loading...")
            </div>
            <div id="formctnr"></div>
        </div>
    </div>
</div>

@section scripts
{
    <script>
        document.currentCulture = '@NOWCulture.CurrentCulture';
        document.uploadUrl = '@Url.Action("UploadImages", "Shared", new { @imageDirectoryUrl = Settings.ProductImageDiretories + Model.ProductId })';
</script>
    @(HttpContext.Current.IsDebuggingEnabled ? Scripts.Render("~/bundles/admin-product-gallery") : Scripts.RenderFormat(@"<script src=""{0}"" async defer></script>", "~/bundles/admin-product-gallery"))
}


